import statsmodels.formula.api as smf
import pandas as pd
import numpy as np
data = pd.DataFrame({"X":np.arange(10,20,0.25)})
data["Y"] =3*data["X"]*data["X"]+ 2 * data["X"] + 1 + np.random.randn(40)
print(data)
mod = smf.ols("Y ~ X", data).fit()
print(mod.summary())
# import matplotlib.pyplot as plt
# data.plot(x="X", y="Y",kind="scatter",figsize=(8,5))
# plt.plot(data["X"], mod.params[0] + mod.params[1]*data["X"],"r")
# plt.text(10, 38, "y="+str(round(mod.params[1],4)) + "*x" + str(round(mod.params[0],4)))
# plt.title("linear regression")
# plt.show()